/**
 * @copyright   2010-2017, The Titon Project
 * @license     http://opensource.org/licenses/BSD-3-Clause
 * @link        http://titon.io
 */

@include export("form") {
    $titon-form-class-field-list: generate-class-name($titon-form, "field-list");
    $titon-form-class-field: generate-class-name($titon-form, "field");
    $titon-form-class-label: generate-class-name($titon-form, "field");
    $titon-form-class-actions: generate-class-name($titon-form, "actions");
    $titon-form-class-help: generate-class-name($titon-form, "help");
    $titon-form-modifiers: map-get($titon-form, "modifiers");

    select[multiple],
    select[size] {
        height: auto;
    }

    input[type="search"] {
        -webkit-appearance: none;
    }

    // Required values to match browser restrictions
    label {
        font-size: inherit;
        line-height: normal;
    }

    //-------------------- Fields, Labels --------------------//

    #{$titon-form-class-field-list} {
        @extend %placeholder-list;

        > li + li {
            margin-top: theme-setting("margin");
        }
    }

    #{$titon-form-class-label} {
        display: block;
        vertical-align: middle;
        margin-bottom: .5em;
    }

    #{$titon-form-class-help} {
        margin-top: .5em;
        font-size: theme-setting("small-font-size");
    }

    #{$titon-form-class-actions} {
        text-align: center;
    }

    //-------------------- Modifiers --------------------//

    @if (is-feature-enabled("all-modifiers") or index($titon-form-modifiers, "inline")) {
        #{generate-class-name($titon-form, "", "inline")} {
            #{$titon-form-class-field-list},
            #{$titon-form-class-field-list} > li,
            #{$titon-form-class-field},
            #{$titon-form-class-label},
            #{$titon-form-class-actions} {
                display: inline-block;
                vertical-align: middle;
                line-height: normal;
                margin: 0;
            }

            #{$titon-form-class-field-list} > li {
                margin-#{bidi-opposite-alignment()}: theme-setting("margin");
            }

            #{$titon-form-class-label} {
                margin-#{bidi-opposite-alignment()}: (theme-setting("margin") / 2);
            }

            #{$titon-form-class-help} {
                display: none;
            }
        }
    }
}
